import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import 'ant-design-vue/dist/reset.css';
import * as Icons from '@ant-design/icons-vue';
import axios from "axios";
import Antd from 'ant-design-vue';
import './assets/js/enums'


const app = createApp(App);
app.use(Antd).use(store).use(router).mount('#app');
// 全局使用图标
const icons = Icons;
for (const i in icons) {
  app.component(i, icons[i]);
}


// 调用前 + 出现错误
axios.interceptors.request.use(function (config) {
  const privateKey = localStorage.getItem('privateKey')
  if (privateKey) {
    config.headers['privateKey'] = privateKey // 将私钥添加到请求头
    console.log("私钥的地址: " + privateKey)
  }
  console.log("私钥的地址: " + privateKey)
  return config;
}, error => {
  console.error("请求错误：", error); // 使用 console.error 输出错误
  return Promise.reject(error);
});

axios.interceptors.response.use(function (response) {
  console.log("返回结果：", response); // 直接输出对象
  return response;
}, error => {
  console.error("返回错误：", error); // 使用 console.error 输出错误
  return Promise.reject(error);
});
axios.defaults.baseURL=process.env.VUE_APP_SERVER_URL;
console.log('环境',process.env.NODE_ENV);
console.log('服务端',process.env.VUE_APP_SERVER_URL);